<template>
	<view class="content">
		<view class="content-item">
			<view class="content-item-data">
				<view>分享人数</view>
				<view>{{teamInfo.team_num}}人</view>
			</view>
			<view class="content-item-data">
				<view>团队人数</view>
				<view>{{teamInfo.team_total_num}}人</view>
			</view>
		</view>
		<view class="content-item">
			<view class="content-item-data">
				<view>个人业绩</view>
				<view>{{teamInfo.yeji}}</view>
			</view>
			<view class="content-item-data">
				<view>团队业绩</view>
				<view>{{teamInfo.team_yeji}}</view>
			</view>
		</view>
	</view>
	<view class="list-content">
		<!-- <view class="list-content-search">
			<uni-search-bar v-model="search" placeholder="请输入编号查询">
				
			</uni-search-bar>
		</view> -->
		<view class="list-content-item" v-for="item,index in teamInfo.userTeam" :key="index">
			<view class="list-content-item-info">
				<image src="/static/logo/logo.jpg" mode="" style="width: 3rem;height: 3rem;border-radius: 35px;"></image>
				<view class="list-content-item-info-c">
					<view class="list-content-item-info-name">
						<text style="margin-right: .6rem;color:black;font-size: 1rem;font-weight: bold;">{{item.uid}}</text>
						<uni-tag :text="item.nickname" type="error" custom-style="width:3rem"></uni-tag>
					</view>
					<view class="list-content-item-info-name">
						<view style="margin-right: .6rem;">直推人数：{{item.team_num}}</view>
						<view>团队人数：{{item.team_total_num}}</view>
					</view>
					<view class="list-content-item-info-name">会员级别：{{item.is_vip}}</view>
					<view class="list-content-item-info-name">注册时间：{{item.create_time}}</view>
				</view>
			</view>
			<view class="list-content-item-yeji">
				<view>
					<view>个人业绩</view>
					<view>{{item.yeji}}</view>
				</view>
				<view>
					<view>团队业绩</view>
					<view>{{item.team_yeji}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				search:null,
				userInfo:null,
				user_token:null,
				teamUserList:null,
				teamInfo:null
			};
		},
		onLoad() {
			this.getUserInfo()
			this.getTeam()
		},
		methods: {
			getUserInfo(){
				let that = this
				if(that.userInfo == null){
					uni.getStorage({
						key: 'user_token',
						success: function (res) {
							that.user_token = res.data
							that.checkUser()
						},
						fail: function(res){
							console.log(res)
							uni.showToast({
								title:'请先登录',
								icon:'none',
								success() {
									uni.redirectTo({
										url:'/pages/login/login',
									})
								}
							})
							
						}
					});
				}
			},
			checkUser(){
				let that = this
				uni.request({
					url:getApp().globalData.baseUrl + '/api/user/getUserInfo',
					method:'POST',
					header: {token:that.user_token},
					success(res) {
						if(res.data.code == 401){
							uni.removeStorage({
								key:'user_token',
								success() {
									uni.showToast({
										icon:'none',
										title:'登录已失效,请重新登录',
										success() {
											setTimeout(function(){
												uni.redirectTo({
													url:'/pages/login/login'
												})
											})
										}
									})
								}
							})
						}
						that.userInfo = res.data.data
						that.form.id_card = that.userInfo.id_card
						that.form.nickname = that.userInfo.nickname
						that.form.mobile = that.userInfo.mobile
					},
					fail() {
						uni.showToast({
							title:'网络错误',
							icon:'none',
						})
					}
				})
			},
			getTeam(){
				let that = this
				uni.request({
					url:getApp().globalData.baseUrl + '/api/user/getTeam',
					method:'POST',
					header:{token:that.user_token},
					success(res) {
						if(res.data.code == 1){
							that.teamInfo = res.data.data
						}else{
							uni.showToast({
								title:res.data.msg,
								icon:'none'
							})
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page{
		background: #f4f4f4;
		
	}
	
	.list-content{
		display: flex;
		flex-direction: column;
	}
	
	.list-content-item-yeji{
		margin-top: 1rem;
		display: flex;
		justify-content: space-around;
		align-items: center;
	}
	
	.list-content-item{
		display: flex;
		flex-direction: column;
		background: #fff;
		margin: .8rem;
		border-radius: 15px;
		padding: .7rem;
	}
	
	.list-content-item-info{
		display: flex;
		
	}
	
	.list-content-search{
		background: #fff;
	}
	
	.list-content-item-info-c{
		display: flex;
		flex-direction: column;
		margin-left: .8rem;
	}
	
	.list-content-item-info-name{
		display: flex;
		margin: .1rem;
		font-size: .8rem;
		color: rgba(39, 39, 39, 1);
	}
	
	.content{
		background-image: url('/static/bag/team_bg.png');
		background-size: 100% auto;
		background-repeat: no-repeat;
		display: flex;
		flex-direction: column;
		padding: 3rem 1rem;
	}
	
	.content-item{
		display: flex;
		justify-content: center;
		margin-bottom: 1rem;
	}
	
	.content-item-data{
		display: flex;
		flex-direction: column;
		padding: .4rem .8rem;
		background: rgb(255, 255, 255, 0.3);
		width: 42%;
		color: white;
		border-radius: 8px 8px 8px 8px;
		align-items: center;
		justify-content: center;
	}
</style>
